<%@ page contentType="application/json; charset=UTF-8" isErrorPage="true"%>
<%@page import="java.sql.SQLException"%>
<%@page import="dbexp.connection.DbAccessException"%>
<%@page import="org.json.JSONObject"%>
<%
JSONObject error = new JSONObject();
if(exception != null) {
	if(exception instanceof SQLException){
		SQLException sqle = (SQLException)exception;
		error.put("title","ERROR CODE:"+sqle.getErrorCode()).put("msg",sqle.getMessage());
		exception.printStackTrace();
	}else if(exception instanceof DbAccessException){
		error.put("title","ERROR:").put("msg",exception.getMessage());
		exception.printStackTrace();
	}else{
	    System.err.println("Communication error: " + exception.getMessage());
	    exception.printStackTrace();
	    error.put("msg",exception.getMessage());
	}
}
out.clearBuffer();%><%=new JSONObject().put("success", false).put("error",error)%>
